public class MethodDemo13 {

    public static void main(String[] args) {
        // 求第5个斐波那契数列
        // 0 1 1 2 3
        int result = f(5);
        System.out.println(result);
    }

    public static int f(int n) {
        if (n == 1) {
            return 0;
        }
        if (n == 2) {
            return 1;
        }
        return f(n - 1) + f(n - 2);
    }
    /*
        f(5) = f(4)+f(3)
        f(4) = f(3)+(f2)
        f(3) = f(2)+f(1)
        f(2) = 1
        f(1) = 0
     */

}
